import zhCN from "./zh_cn";
import zhHK from "./zh_hk";

export default {
    "zh-CN": zhCN,
    "zh-HK": zhHK,
    getLocale() {
        let lang = localStorage["locale"];

        if (lang == null) {
            lang = navigator.language;
        }

        if (!(lang in this)) {
            lang = "zh-CN";
        }

        localStorage["locale"] = lang;

        return lang;
    },
    saveLocale(lang) {
        if (lang in this) {
            localStorage["locale"] = lang;
        } else {
            console.error(`i18n: 设置站点语言为${lang}失败，不存在该语言包`);
        }
    }
}